﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SES.CMS.BL;
using SES.CMS.DO;
using System.Data;

namespace SES.CMS
{
    public partial class ListAlbum : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MasterPage mt = this.Master as MasterPage;
            Control uc = mt.FindControl("ucHomeSlide1") as Control;
            uc.Visible = false;
            if (!IsPostBack)
                rptAlbumParentDataSource();
        }

        protected void rptAlbumParentDataSource()
        {
            rptAlbumParent.DataSource = new DataView(new cmsAlbumBL().SelectAll(), "ParentID = 0", "", DataViewRowState.CurrentRows);
            rptAlbumParent.DataBind();
        }
        protected void rptAlbumParent_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem item = e.Item;
            Repeater rptAlbumDetail = (Repeater)e.Item.FindControl("rptAlbumDetail");
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                DataRowView drv = (DataRowView)item.DataItem;
                int parentID = int.Parse(drv["AlbumID"].ToString());

                rptAlbumDetail.DataSource = new DataView(new cmsAlbumBL().SelectAll(), "ParentID = " + parentID , "", DataViewRowState.CurrentRows);
                rptAlbumDetail.DataBind();
            }

        }
    }
}